package utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class JDBCDog {
	private static final String DRV = "oracle.jdbc.OracleDriver";
	private static final String URL = "jdbc:oracle:thin:@//localhost:1521/xe";
	private static final String USR = "scott";
	private static final String PWD = "TIGER";
	
	public static Connection openConn() {
		Connection conn = null;
		try {
			Class.forName(DRV);
			conn = DriverManager.getConnection(URL, USR, PWD);
		} catch (Exception ex) {
			ex.printStackTrace();
		} 
		return conn;
	}
	
	public static void closeConn(Connection c, PreparedStatement p, ResultSet r) {
		if (r != null) { try { r.close(); } catch (Exception e) { } }
		if (p != null) { try { p.close(); } catch (Exception e) { } }
		if (c != null) { try {c.close(); } catch (Exception e) { } }
	}

}
